package com.example.controller;

import com.alibaba.fastjson.JSONObject;
import com.example.service.MFileService;
import com.example.utils.LuceneUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * lunce搜索示例
 */
@RestController
@RequestMapping("lunece")
public class LuneceController {

    @Autowired
    private MFileService mFileService;

    @GetMapping("create")
    public JSONObject createMFileController() throws Exception{
        List<Map<String, Object>> maps=mFileService.listMaps();
        LuceneUtils.addListDocumentByIndexName("m_file",maps);
        return new JSONObject();
    }

    @GetMapping("search")
    public Object getSearch() throws Exception{
       List<Map<String, Object>> object=LuceneUtils.searchByKeyWord("m_file","id","1",1);
       return object;
    }
}
